package com.asa.mvvm_aop_frame.basic

import android.app.Application
import android.content.Context
import me.jessyan.autosize.AutoSizeConfig

/**
 * create By：anderson
 * on 2022/4/27
 * desc:
 */
class BaseApp private constructor(){

    private var context : Context ?= null

    companion object{
        val instance : BaseApp by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
            BaseApp()
        }

        const val DESIGN_WIDTH_INDP = 411
        const val DESIGN_HEIGHT_INDP = 731
    }


    /**
     *  获取context不需要下沉
     */
    fun getContext(): Context? {
        if (context == null){
            val application = Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null) as Application
            context = application.applicationContext
        }
        return context
    }


    fun init(designWidthInDp:Int,designHeightInDp:Int){
        AutoSizeConfig.getInstance().designWidthInDp = designWidthInDp
        AutoSizeConfig.getInstance().designHeightInDp = designHeightInDp
        AutoSizeConfig.getInstance().isExcludeFontScale = true
    }



}